/*
  GNU  Klub RFID  door  interface program  Copyright  (C) 2008,  hepek
  (http://gnu.elfak.ni.ac.yu) zivotinja [at] gmail [dot] com
  
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//this header provides interface functions that communicate with RFID door hardware


#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>

struct termios serial_params;
char  buff_scheme[256]; //used in scheme version of serial readln

//returns fd of the interface
int serial_init(char* deviceName);
//in case of an error, do hardware reset on the device
int serial_reset(int fd, char* deviceName);
//read one line of data (terminated with cr lf)
char * serial_readln(int fd, char* buffer,int buffer_size);
char * serial_readln_scheme(int fd);
int serial_flush(int fd);

//door interface
int door_open(int fd,int timeout);
int door_close(int fd);

int door_test(int);

char * door_string(char * buffer, int i);
